import axios from '@/utils/request';

/**
 * 查询banner列表
 */
export async function GetBanner(params) {
  const res = await axios.post('/Banner/QueryBannerByCondition', params);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 * 删除banner
 */
export async function DelBanner(params) {
  const res = await axios.post(`/Banner/DeleteBanner?id=${params.id}`);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 * 获取guid
 */
export async function GetGuid(id) {
  const res = await axios.get('/Attchment/GetGuid');
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}



/**
 * 新增banner
 */
export async function AddBanner(params) {
  const res = await axios.post('/Banner/AddBanner', params);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 * 新增banner图片上传
 */
export async function UploadFile(params) {
  const res = await axios.post('/Attchment/UploadFile', params);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 * 获取banner 详情
 */
export async function GetBannerDetail(params) {
  const res = await axios.get(`/Banner/QueryBannerById?id=${params.id}`);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 *  修改banner
 */
export async function EditBanner(params) {
  const res = await axios.post('/Banner/UpdateBanner', params);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 * 查询规格列表
 */
export async function QueryProductSpecitemsByCondition(params) {
  const res = await axios.post('/ProductSpecItem/QueryProductSpecitemsByCondition', params);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 * 新增规格
 */
export async function AddProductSpecitems(params) {
  const res = await axios.post('/ProductSpecItem/AddProductSpecitems', params);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}



/**
 * 获取规格详情
 */
export async function QueryProductSpecitemsById(params) {
  const res = await axios.get(`/ProductSpecItem/QueryProductSpecitemsById?id=${params.id}`);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}



/**
 *  修改规格
 */
export async function UpdateProductSpecitems(params) {
  const res = await axios.post('/ProductSpecItem/UpdateProductSpecitems', params);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}



/**
 * 删除banner
 */
export async function DeleteProductSpecitems(params) {
  const res = await axios.post(`/ProductSpecItem/DeleteProductSpecitems?id=${params.id}`);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}
/**
 * 获取字典值
 */
export async function QueryAllChildDictViewByCode(params) {
  const res = await axios.get(`Dict/QueryAllChildDictViewByCode?code=${params.code}`);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}